package com.migo.thread.service;

import com.aliyun.openservices.aliyun.log.producer.LogProducer;
import com.aliyun.openservices.aliyun.log.producer.Producer;
import com.aliyun.openservices.aliyun.log.producer.ProducerConfig;
import com.aliyun.openservices.aliyun.log.producer.ProjectConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SLSUtils {


    private static final Logger LOGGER = LoggerFactory.getLogger(SLSUtils.class);


    public static Producer createProducer() {
        ProducerConfig producerConfig = new ProducerConfig();
        Producer producer = new LogProducer(producerConfig);
        producer.putProjectConfig(buildProjectConfig());
        return producer;
    }

    private static ProjectConfig buildProjectConfig() {
        String project = "vision-plus";
        String endpoint = "cn-hongkong.log.aliyuncs.com";
        String accessKeyId = "LTAI1f1IvJ4gaW1Y";
        String accessKeySecret = "utIEW0SCOvMSHBuG1DO8S9goVWbP41";
        return new ProjectConfig(project, endpoint, accessKeyId, accessKeySecret);
    }


    public static void doSomething() throws InterruptedException {
        LOGGER.info("Before doSomething");
        Thread.sleep(3000);
        LOGGER.info("After doSomething");
    }

}
